<?php
include_once("../modules/checkA.php");
include_once("../../config.php");
?>


<?php

$code_date="http://vars.enpingshi.com/user/checkin.php?eid=".$_REQUEST['eid'];
$chepai=preg_replace('/([\x80-\xff]*)/i','',$_REQUEST['name']);

$_REQUEST['data']=$code_date;


//set it to writable location, a place for temp generated PNG files
$PNG_TEMP_DIR = ROOT_PATH_.'/uploadfiles/store/';

//html PNG location prefix
$PNG_WEB_DIR = $host.'/uploadfiles/store/';

include ROOT_PATH_."/application/phpqrcode/qrlib.php";

//ofcourse we need rights to create temp dir
if (!file_exists($PNG_TEMP_DIR))
    mkdir($PNG_TEMP_DIR);


$filename = $PNG_TEMP_DIR.'test.png';

//processing form input
//remember to sanitize user input in real-life solution !!!
$errorCorrectionLevel = 'L';
if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
    $errorCorrectionLevel = $_REQUEST['level'];

$matrixPointSize = 100;
if (isset($_REQUEST['size']))
    $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 100);


if (isset($_REQUEST['data'])) {

    //it's very important!
    if (trim($_REQUEST['data']) == '')
        die('data cannot be empty! <a href="?">back</a>');

    // user data
    $filename = $PNG_TEMP_DIR.$chepai.'.png';


    QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2);

} else {


    QRcode::png('PHP QR Code :)', $filename, $errorCorrectionLevel, $matrixPointSize, 2);

}

//display generated file

echo '<img src="http://'.$PNG_WEB_DIR.basename($filename).'" /><hr/>';

header('Location:http://'.$PNG_WEB_DIR.basename($filename));


// benchmark
//QRtools::timeBenchmark();

    